package Code;

import java.util.HashMap;
import java.util.Map;

public class Code1 {
    static  int[] twoSum(int[] nums, int target){
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i< nums.length; i++){
            int tmp = target - nums[i];
            if(map.containsKey(tmp)){
                return new int[]{map.get(tmp), i};
            }
            map.put(nums[i], i);

        }
        return new int[]{-1,-1};
    }
    public static void main(String[] args) {
        int[] nums = {2,7,11, 15};
        int target = 9;
        System.out.println(twoSum(nums, target)[0] +" " + twoSum(nums,target)[1]);
    }
}
